package framework.editors
{
	import org.as3commons.reflect.Field;
	import org.as3commons.reflect.Type;

	public class DefaultPropertyLister implements IPropertyLister
	{
		public function DefaultPropertyLister()
		{
		}

		public function canList(obj:*):int
		{
			if (!(obj is XML || obj is XMLList))
				return 1;
			return 0;
		}

		public function isDynamic(obj:*):Boolean
		{
			return Type.forInstance(obj).isDynamic;
		}

		public function list(obj:*):Array
		{
			var r:Array = [];
			for each (var f:Field in Type.forInstance(obj).fields)
			{
				if (f.name == "prototype")
					continue;
				var op:ObjectProperty = new ObjectProperty;
				var clazz:Class = f.type.clazz;
				op.isComplex = !(clazz == Number || clazz == String || clazz == int ||
					clazz == Boolean);
				op.propName = f.name;
				r.push(op);
			}
			return r;
		}
	}
}